import { fileToBase64, base64ToFile } from '../tool.js'
import { sendjson } from '../../cloud_apps/client.js'
var host = '127.0.0.1';
var port =3473;
async function flipHorizontal(ipath, opath, k,houzhui) {
	let resultjson = await sendjson({
		'sign': 'func',
		'func':'flipHorizontal',
		'img': await fileToBase64(ipath),
		'params': [k,houzhui]
	},host,port)
	if (resultjson.sign == 'error') {
		console.log('服务端已响应，但发生未知错误')
	} else {
		await base64ToFile(resultjson.img, opath)
	}
}
async function flipVertical(ipath, opath, k,houzhui) {
	let resultjson = await sendjson({
		'sign': 'func',
		'func':'flipVertical',
		'img': await fileToBase64(ipath),
		'params': [k,houzhui]
	},host,port)
	if (resultjson.sign == 'error') {
		console.log('服务端已响应，但发生未知错误')
	} else {
		await base64ToFile(resultjson.img, opath)
	}
}
async function create3DRotationGIF(ipath, opath,houzhui) {
	let resultjson = await sendjson({
		'sign': 'func',
		'func':'create3DRotationGIF',
		'img': await fileToBase64(ipath),
		'params': [houzhui]
	},host,port)
	if (resultjson.sign == 'error') {
		console.log('服务端已响应，但发生未知错误')
	} else {
		await base64ToFile(resultjson.img, opath)
	}
}
async function imgresize(ipath, opath, k,houzhui) {
	let resultjson = await sendjson({
		'sign': 'func',
		'func':'imgresize',
		'img': await fileToBase64(ipath),
		'params': [k,houzhui]
	},host,port)
	if (resultjson.sign == 'error') {
		console.log('服务端已响应，但发生未知错误')
	} else {
		await base64ToFile(resultjson.img, opath)
	}
}
export { flipHorizontal, flipVertical, create3DRotationGIF,imgresize }